package com.chapter.sample.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        /*System.out.println("com.chapter.sample.processor.MyBeanFactoryPostProcessor");

        //BeanDefinition userService = beanFactory.getBeanDefinition("userService");
        //userService.setBeanClassName("com.chapter.sample.dao.impl.UserDaoImpl");

        BeanDefinition beanDefinition = new RootBeanDefinition();
        beanDefinition.setBeanClassName("com.chapter.sample.dao.impl.PersonDaoImpl");

        DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
        defaultListableBeanFactory.registerBeanDefinition("person",beanDefinition);
*/

    }
}
